package dca;

import java.util.ArrayList;

public class Patient implements Comparable<Object>{
	
	private String name;
	private int health;
	private ArrayList<Symptom> symptoms;
	public static int max_healt=100;
	
	
	
	//This constructor allows you to add patients with or without symptoms. Useful when the staff cannot immediately identify the symptoms.

	public Patient(String name, int health) throws BadDataException{
		this.name = name;
		this.health = health;
	}
	public Patient(String name, int health,ArrayList<Symptom> symptoms) throws BadDataException{
		this(name, health);
		this.symptoms = symptoms;		
	}
	
	
	/**
	 * Heals the patient a number of percentage points. A patient cannot be healed to above 100% health. 
	 * @param percentPoint
	 * @throws BadDataException 
	 */
	public void heal(int percentPoint) throws BadDataException{
		health+=percentPoint;
		if(health>=100)
		{
			health=100;
			symptoms=new ArrayList<Symptom>();
			symptoms.add(new Symptom("healty","Trivial"));
		}
	}
	
	public String toString(){
		String IDString =  name+":"+health+"%";
		String symptomString="";
		if(!(symptoms==null)){
			for(int i=0;i<symptoms.size();i++)
			{
				symptomString += symptoms.get(i).toString();
				if(i<symptoms.size()-1)
					symptomString+=","; 
			}
		}
		return IDString+"\n"+symptomString;
	}
	
	public ArrayList<Symptom> getSymptoms(){
		return this.symptoms;
	}
	
	public String getName(){
		return this.name;
	}
	
	public int getHealth(){
		return this.health;
	}
	
	public int compareTo(Object anotherObject){
		if(!(anotherObject instanceof Patient))
			throw new ClassCastException("Can only compare patients to other patients");
		Patient anotherPatient = (Patient) anotherObject;
		return this.name.compareToIgnoreCase(anotherPatient.name);
	}

}
